package com.chanzany.interview_primary;

import lombok.AllArgsConstructor;

import java.util.Objects;

@AllArgsConstructor
class Cat{
   private int age;
   private String name;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cat cat = (Cat) o;
        return age == cat.age &&
                Objects.equals(name, cat.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(age, name);
    }
}


public class TestEqual {
    public static void main(String[] args) {
        Cat tom = new Cat(1, "tom");
        Cat tom2 = new Cat(1, "tom");
        System.out.println(tom == tom2);
        System.out.println(tom.equals(tom2));

    }
}

